package wangwenjun.phase2.concurrencypattern.activeobject.dynamicproxy;

import lombok.extern.slf4j.Slf4j;
import util.ThreadUtil;
import wangwenjun.phase2.concurrencypattern.future.Future;
import wangwenjun.phase2.concurrencypattern.future.FutureServiceFactory;


/**
 * @author ChangLiang
 * @date 2020/6/17
 */
@Slf4j
public class OrderServiceImpl implements OrderService {

    @Override
    public void createOrder(String account, long orderId) {
        ThreadUtil.sleepForSeconds(5);
        log.info("create order for account:{}, orderId:{}", account,orderId);
    }

    @Override
    public Future<String> findOrderDetails(long orderId) {
        return FutureServiceFactory.<Long,String>newService().submit(input -> {
            ThreadUtil.sleepForSeconds(5);
            log.info("find order details for orderId:{}", orderId);
            return "the order#" + orderId + " details";
        }, orderId, null);
    }
}
